package com.youthfilmic.yuejian.controller;

import com.youthfilmic.yuejian.dao.SubjectDao;
import com.youthfilmic.yuejian.domain.DomainInfo;
import com.youthfilmic.yuejian.domain.Subject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * Created by youweixi on 15/10/11.
 */
@Controller
@RequestMapping("/main/topic")
public class TopicController {
    @Resource
    private SubjectDao subjectDao;

    @RequestMapping("/business")
    public String showBusiness(Model model){
        Page<Subject> page = subjectDao.findByTypeAndStatus(0, Subject.SATUS_SUCCEED, new PageRequest(0, 10,new Sort(Sort.Direction.DESC , "postAt")));
        model.addAttribute("subjects" , page.getContent());
        return "main/topic/topic-business";
    }

    @RequestMapping("/learn")
    public String showLearn(Model model){
        Page<Subject> page = subjectDao.findByTypeAndStatus(1, Subject.SATUS_SUCCEED, new PageRequest(0, 10,new Sort(Sort.Direction.DESC , "postAt")));
        model.addAttribute("subjects" , page.getContent());
        return "main/topic/topic-learn";
    }

    @RequestMapping("/more")
    public String showMore(){
        return "main/topic/topic-more";
    }

    @RequestMapping("/activity")
    public String showActivity(){
        return "main/topic/topic-activity";
    }



}
